/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.ajz.web;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.thinkgem.jeesite.common.beanvalidator.BeanValidators;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.common.utils.excel.ImportExcel;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.ajz.entity.*;
import com.thinkgem.jeesite.modules.ajz.service.*;
import com.thinkgem.jeesite.modules.sys.entity.Dict;
import com.thinkgem.jeesite.modules.sys.entity.Office;
import com.thinkgem.jeesite.modules.sys.entity.Role;
import com.thinkgem.jeesite.modules.sys.entity.User;
import com.thinkgem.jeesite.modules.sys.service.OfficeService;
import com.thinkgem.jeesite.modules.sys.service.SystemService;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 门店区域划分表Controller
 * @author whh
 * @version 2017-09-14
 */
@Controller
@RequestMapping(value = "${adminPath}/ajz/ajzBaseinfo")
public class AjzBaseinfoController extends BaseController {
	//tableName
	private static final String AQTABLENAME="ajz_aqsc";
	private static final String SPTABLENAME="ajz_sp";
	private static final String RQGDTABLENAME="ajz_ri_gd";
	private static final String RQGHTABLENAME="ajz_ri_gh";
	private static final String XFCZWTABLENAME="ajz_xf_czw";
	private static final String XFDMTABLENAME="ajz_xf_dm";
	//excel head name
	private static final String AQFILENAME = "安全生产数据";
	private static final String SPFILENAME = "食品安全数据";
	private static final String RQGDFILENAME = "燃气管道数据";
	private static final String RQGHFILENAME = "燃气液化石油数据";
	private static final String XFCZWFILENAME = "消防出租屋数据";
	private static final String XFDMFILENAME = "消防门店数据";
	
	@Autowired
	private AjzRecordService ajzRecordService;
	
	@Autowired
	private OfficeService officeService;
	
	@Autowired
	private SystemService systemService;
	
	@Autowired
	private AjzRiGdService ajzRiGdService;

	@Autowired
	private AjzRiGhService ajzRiGhService;

	@Autowired
	private AjzXfCzwService ajzXfCzwService;

	@Autowired
	private AjzXfDmService ajzXfDmService;

	@Autowired
	private AjzBaseinfoService ajzBaseinfoService;
	
	@Autowired
	private AjzRiViewGdService ajzRiViewGdService;

	@Autowired
	private AjzRiViewGhService ajzRiViewGhService;

	@Autowired
	private AjzXfViewCzwService ajzXfViewCzwService;

	@Autowired
	private AjzXfViewDmService ajzXfViewDmService;

	@Autowired
	private AjzViewBaseinfoService ajzViewBaseinfoService;
	
	@ModelAttribute
	public AjzBaseinfo get(@RequestParam(required=false) String id) {
		AjzBaseinfo entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = ajzBaseinfoService.get(id);
		}
		if (entity == null){
			entity = new AjzBaseinfo();
		}
		return entity;
	}
	
	/**
	 * 文件下载
	 * @param filePath
	 * @param response
	 * @param filename
	 */
	@SuppressWarnings("resource")
	public void downLoadFile(String filePath,HttpServletResponse response,String filename){
		BufferedOutputStream bufferOut = null;
		BufferedInputStream bufferIn = null;
		try {
		      bufferIn = new BufferedInputStream(new FileInputStream(filePath));
		      bufferOut = new BufferedOutputStream(response.getOutputStream());
		      response.setCharacterEncoding("UTF-8");
		      response.setHeader("Content-disposition","attachment; filename="+new String(filename.getBytes("UTF-8"),"iso8859-1"));
		      byte[] Byte = new byte[1024];
		      int len=0;
		      while(-1!=(len=bufferIn.read(Byte))){
		    	  bufferOut.write(Byte,0,len);
		      }
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			if(null != bufferOut){
				try {
					bufferOut.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			if(null != bufferIn){
				try {
					bufferIn.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}
	
	/**
	 * 转换成json格式
	 */
	public static StringWriter Message2Json(Object obj){
		StringWriter str = new StringWriter();
		ObjectMapper objMapper = new ObjectMapper();
		try {
			objMapper.writeValue(str,obj);
		}catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return str;
	}
	
	/*
	 * 打印返回信息
	 */
	public void backMessage(HttpServletResponse response,Object obj){
		StringWriter str = Message2Json(obj);
		PrintWriter writer = null;
		try {
		    writer = response.getWriter();
		} catch (IOException e) {
			e.printStackTrace();
		}
		writer.println(str);
	}
	
	/*
	 *获取请求参数 
	 */
	public HashMap<String,String> getParameter(HttpServletRequest request){
		HashMap<String,String> parameter = new HashMap<String,String>();
		Enumeration<String> names = request.getParameterNames();
		while(names.hasMoreElements()){
			String key = names.nextElement();
			parameter.put(key,request.getParameter(key));
		}
		return parameter;
	}
	
	/**
	 * excel表导入
	 * @param file
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "import",method=RequestMethod.POST)
	public String importFile(MultipartFile file, RedirectAttributes redirectAttributes){
		try {
			int successNum = 0;
			int failureNum = 0;
			StringBuilder failureMsg = new StringBuilder();
			ImportExcel ei = new ImportExcel(file, 1, 0);
			Cell cell = ei.getRow(0).getCell(0);
			String stringCellValue = cell.getStringCellValue();
			if(StringUtils.equals(stringCellValue,AQFILENAME)){
				importanquan(ei,successNum,failureNum,failureMsg,redirectAttributes,AQTABLENAME);
			}else if(StringUtils.equals(stringCellValue,SPFILENAME)){
				importanquan(ei,successNum,failureNum,failureMsg,redirectAttributes,SPTABLENAME);
			}else if(StringUtils.equals(stringCellValue,XFCZWFILENAME)){
				importchuzuwu(ei,successNum,failureNum,failureMsg,redirectAttributes,XFCZWTABLENAME);
			}else if(StringUtils.equals(stringCellValue,XFDMFILENAME)){
				importdianmian(ei,successNum,failureNum,failureMsg,redirectAttributes,XFDMTABLENAME);
			}else if(StringUtils.equals(stringCellValue,RQGDFILENAME)){
				importguandao(ei,successNum,failureNum,failureMsg,redirectAttributes,RQGDTABLENAME);
			}else if(StringUtils.equals(stringCellValue,RQGHFILENAME)){
				importganghua(ei,successNum,failureNum,failureMsg,redirectAttributes,RQGHTABLENAME);
			}
		} catch (Exception e) {
			addMessage(redirectAttributes, "导入用户失败！失败信息："+e.getMessage());
		}
		return "redirect:" + adminPath + "/ajz/ajzBaseinfo/list?repage";
	}
	
	/**
	 * 导入钢化模板数据
	 * @param ei
	 * @param successNum
	 * @param failureNum
	 * @param failureMsg
	 * @throws InstantiationException
	 * @throws IllegalAccessException
	 */
	public void importganghua(ImportExcel ei,int successNum,int failureNum,StringBuilder failureMsg,RedirectAttributes redirectAttributes,String tableName) throws InstantiationException, IllegalAccessException{
		List<AjzRiViewgh> list = ei.getDataList(AjzRiViewgh.class);
		for (AjzRiViewgh ajzRiViewgh : list){
			Map<String, Object> map = transBean2Map(ajzRiViewgh);
			String tele =(String)map.get("telephone");
			if(StringUtils.isNotBlank(tele)){
				BigDecimal big = new BigDecimal(tele);
				map.put("telephone",big.toString());
			}else{
				failureNum++;
				continue;
			}
			AjzBaseinfo ajzBaseinfo= new AjzBaseinfo();
			AjzRiGh ajzRiGh =new AjzRiGh();
			autoAssembling(map,ajzBaseinfo);
			autoAssembling(map,ajzRiGh);
			List<Dict> gasCompanyList = ajzBaseinfoService.findSelectList("gas_company");
			List<Dict> purchaseVoucherList = ajzBaseinfoService.findSelectList("purchase_voucher");
			List<Dict> gasTypeList = ajzBaseinfoService.findSelectList("gas_type");
			List<Dict> gasPropertyList = ajzBaseinfoService.findSelectList("gas_property");
			ajzRiGh.setPurchaseVoucher("1");
			ajzRiGh.setGasType("1");
			ajzRiGh.setGasProperty("1");
			ajzRiGh.setGasCompany("1");
			for(Dict dict : purchaseVoucherList){
				if(StringUtils.equals(dict.getLabel(),(CharSequence)map.get("purchaseVoucher"))){
					ajzRiGh.setPurchaseVoucher(dict.getValue());
				}
			}for(Dict dict : gasTypeList){
				if(StringUtils.equals(dict.getLabel(),(CharSequence)map.get("gasType"))){
					ajzRiGh.setGasType(dict.getValue());
				}
			}for(Dict dict : gasPropertyList){
				if(StringUtils.equals(dict.getLabel(),(CharSequence)map.get("gasProperty"))){
					ajzRiGh.setGasProperty(dict.getValue());
				}
			}
			for(Dict dict : gasCompanyList){
				if(StringUtils.equals(dict.getLabel(),(CharSequence)map.get("gasCompany"))){
					ajzRiGh.setGasCompany(dict.getValue());
				}
			}
			try{
				if (checkTelephone(ajzBaseinfo.getTelephone())){
					saveAjzBaseinfo(ajzBaseinfo,tableName);
					ajzRiGh.setBaseinfoId(ajzBaseinfo.getId());
					ajzRiGhService.save(ajzRiGh);
					successNum++;
				}else{
					String baseinfoId = systemService.getUserByLoginName(ajzBaseinfo.getTelephone()).getNo();
					AjzBaseinfo newajzBaseinfo = ajzBaseinfoService.get(baseinfoId);
					String lastTableName = checkTableName(newajzBaseinfo.getTableName(),tableName);
					ajzBaseinfo.setTableName(lastTableName);
				    ajzBaseinfoService.save(newajzBaseinfo);
				    AjzRiGh realajzrigh = ajzRiGhService.getRealAjzRiGhByBaseinfoId(baseinfoId);
				    if(null != realajzrigh){
				    	ajzRiGh.setId(realajzrigh.getId());
				    }
					ajzRiGh.setBaseinfoId(baseinfoId);
					ajzRiGhService.save(ajzRiGh);
					successNum++;
				}
			}catch(ConstraintViolationException ex){
				failureMsg.append("<br/>单位 "+ajzRiViewgh.getEnterpriseName()+" 导入失败：");
				List<String> messageList = BeanValidators.extractPropertyAndMessageAsList(ex, ": ");
				for (String message : messageList){
					failureMsg.append(message+"; ");
					failureNum++;
				}
			}catch (Exception ex) {
				failureMsg.append("<br/>单位"+ajzRiViewgh.getEnterpriseName()+" 导入失败："+ex.getMessage());
			}
		}
		if (failureNum>0){
			failureMsg.insert(0, "，失败 "+failureNum+" 条用户，导入信息如下：");
		}
		addMessage(redirectAttributes, "已成功导入 "+successNum+" 条用户"+failureMsg);
	}
	
	/**
	 * 导入出租屋模板数据
	 * @param ei
	 * @param successNum
	 * @param failureNum
	 * @param failureMsg
	 * @throws InstantiationException
	 * @throws IllegalAccessException
	 */
	public void importchuzuwu(ImportExcel ei,int successNum,int failureNum,StringBuilder failureMsg,RedirectAttributes redirectAttributes,String tableName) throws InstantiationException, IllegalAccessException{
		List<AjzXfViewczw> list = ei.getDataList(AjzXfViewczw.class);
		for (AjzXfViewczw ajzXfViewczw : list){
			Map<String, Object> map = transBean2Map(ajzXfViewczw);
			String tele =(String)map.get("telephone");
			if(StringUtils.isNotBlank(tele)){
				BigDecimal big = new BigDecimal(tele);
				map.put("telephone",big.toString());
			}else{
				failureNum++;
				continue;
			}
			AjzBaseinfo ajzBaseinfo= new AjzBaseinfo();
			AjzXfCzw ajzXfCzw = new AjzXfCzw();
			autoAssembling(map,ajzBaseinfo);
			autoAssembling(map,ajzXfCzw);
			try{
				if (checkTelephone(ajzBaseinfo.getTelephone())){
					saveAjzBaseinfo(ajzBaseinfo,tableName);
					ajzXfCzw.setBaseinfoId(ajzBaseinfo.getId());
					ajzXfCzwService.save(ajzXfCzw);
					successNum++;
				}else{
					String baseinfoId = systemService.getUserByLoginName(ajzBaseinfo.getTelephone()).getNo();
					AjzBaseinfo newajzBaseinfo = ajzBaseinfoService.get(baseinfoId);
					String lastTableName = checkTableName(newajzBaseinfo.getTableName(),tableName);
					ajzBaseinfo.setTableName(lastTableName);
				    ajzBaseinfoService.save(newajzBaseinfo);
				    AjzXfCzw realajzxfczw = ajzXfCzwService.getRealAjzXfCzwByBaseinfo(baseinfoId);
				    if(null != realajzxfczw){
				    	ajzXfCzw.setId(realajzxfczw.getId());
				    }
					ajzXfCzw.setBaseinfoId(baseinfoId);
					ajzXfCzwService.save(ajzXfCzw);
					successNum++;
				}
			}catch(ConstraintViolationException ex){
				failureMsg.append("<br/>单位 "+ajzXfViewczw.getEnterpriseName()+" 导入失败：");
				List<String> messageList = BeanValidators.extractPropertyAndMessageAsList(ex, ": ");
				for (String message : messageList){
					failureMsg.append(message+"; ");
					failureNum++;
				}
			}catch (Exception ex) {
				failureMsg.append("<br/>单位"+ajzXfViewczw.getEnterpriseName()+" 导入失败："+ex.getMessage());
			}
		}
		if (failureNum>0){
			failureMsg.insert(0, "，失败 "+failureNum+" 条用户，导入信息如下：");
		}
		addMessage(redirectAttributes, "已成功导入 "+successNum+" 条用户"+failureMsg);
	}
	
	/**
	 * 导入店面模板数据
	 * @param ei
	 * @param successNum
	 * @param failureNum
	 * @param failureMsg
	 * @throws InstantiationException
	 * @throws IllegalAccessException
	 */
	public void importdianmian(ImportExcel ei,int successNum,int failureNum,StringBuilder failureMsg,RedirectAttributes redirectAttributes,String tableName) throws InstantiationException, IllegalAccessException{
		List<AjzXfViewdm> list = ei.getDataList(AjzXfViewdm.class);
		for (AjzXfViewdm ajzXfViewdm : list){
			Map<String, Object> map = transBean2Map(ajzXfViewdm);
			String tele =(String)map.get("telephone");
			if(StringUtils.isNotBlank(tele)){
				BigDecimal big = new BigDecimal(tele);
				map.put("telephone",big.toString());
			}else{
				failureNum++;
				continue;
			}
			AjzBaseinfo ajzBaseinfo= new AjzBaseinfo();
			AjzXfDm ajzXfDm = new AjzXfDm();
			autoAssembling(map,ajzBaseinfo);
			autoAssembling(map,ajzXfDm);
			List<Dict> placeCategoryList = ajzBaseinfoService.findSelectList("place_category");
			List<Dict> fireAuditList = ajzBaseinfoService.findSelectList("fire_audit");
			ajzXfDm.setFireAudit("1");
			ajzXfDm.setPlaceCategory("1");
			for(Dict dict:fireAuditList){
				if(dict.getLabel() == map.get("fireAudit")){
					ajzXfDm.setFireAudit(dict.getValue());
				}	
			}
			for(Dict dict:placeCategoryList){
				if(dict.getLabel() == map.get("placeCategory")){
					ajzXfDm.setPlaceCategory(dict.getValue());
				}	
			}
			try{
				if (checkTelephone(ajzBaseinfo.getTelephone())){
					saveAjzBaseinfo(ajzBaseinfo,tableName);
					ajzXfDm.setBaseinfoId(ajzBaseinfo.getId());
					ajzXfDmService.save(ajzXfDm);
					successNum++;
				}else{
				    String baseinfoId = systemService.getUserByLoginName(ajzBaseinfo.getTelephone()).getNo();
					AjzBaseinfo newajzBaseinfo = ajzBaseinfoService.get(baseinfoId);
					String lastTableName = checkTableName(newajzBaseinfo.getTableName(),tableName);
					ajzBaseinfo.setTableName(lastTableName);
				    ajzBaseinfoService.save(newajzBaseinfo);
				    AjzXfDm realajzxfdm = ajzXfDmService.getRealAjzXfDmByBaseinfoId(baseinfoId);
				    if(null != realajzxfdm){
				    	ajzXfDm.setId(realajzxfdm.getId());
				    }
					ajzXfDm.setBaseinfoId(baseinfoId);
					ajzXfDmService.save(ajzXfDm);
					successNum++;
				}
			}catch(ConstraintViolationException ex){
				failureMsg.append("<br/>单位 "+ajzXfViewdm.getEnterpriseName()+" 导入失败：");
				List<String> messageList = BeanValidators.extractPropertyAndMessageAsList(ex, ": ");
				for (String message : messageList){
					failureMsg.append(message+"; ");
					failureNum++;
				}
			}catch (Exception ex) {
				failureMsg.append("<br/>单位"+ajzXfViewdm.getEnterpriseName()+" 导入失败："+ex.getMessage());
			}
		}
		if (failureNum>0){
			failureMsg.insert(0, "，失败 "+failureNum+" 条用户，导入信息如下：");
		}
		addMessage(redirectAttributes, "已成功导入 "+successNum+" 条用户"+failureMsg);
	}
	
	/**
	 * 导入管道模板数据
	 * @param ei
	 * @param successNum
	 * @param failureNum
	 * @param failureMsg
	 * @throws InstantiationException
	 * @throws IllegalAccessException
	 */
	public void importguandao(ImportExcel ei,int successNum,int failureNum,StringBuilder failureMsg,RedirectAttributes redirectAttributes,String tableName) throws InstantiationException, IllegalAccessException{
		List<AjzRiViewgd> list = ei.getDataList(AjzRiViewgd.class);
		for (AjzRiViewgd ajzRiViewgd : list){
			Map<String, Object> map = transBean2Map(ajzRiViewgd);
			String tele =(String)map.get("telephone");
			if(StringUtils.isNotBlank(tele)){
				BigDecimal big = new BigDecimal(tele);
				map.put("telephone",big.toString());
			}else{
				failureNum++;
				continue;
			}
			AjzRiGd ajzRigd= new AjzRiGd();
			AjzBaseinfo ajzBaseinfo = new AjzBaseinfo();
			autoAssembling(map,ajzRigd);
			autoAssembling(map,ajzBaseinfo);
			List<Dict> gasPropertyList = ajzBaseinfoService.findSelectList("gas_property");
			ajzRigd.setGasProperty("1");
			for(Dict dict:gasPropertyList){
				if(StringUtils.equals(dict.getLabel(),(CharSequence) map.get("gasProperty"))){
					ajzRigd.setGasProperty(dict.getValue());
				}
			}
			try{
				if (checkTelephone(ajzBaseinfo.getTelephone())){
					saveAjzBaseinfo(ajzBaseinfo,tableName);
					ajzRigd.setBaseinfoId(ajzBaseinfo.getId());
					ajzRiGdService.save(ajzRigd);
					successNum++;
				}else{
				    String baseinfoId = systemService.getUserByLoginName(ajzBaseinfo.getTelephone()).getNo();
					AjzBaseinfo newajzBaseinfo = ajzBaseinfoService.get(baseinfoId);
					String lastTableName = checkTableName(newajzBaseinfo.getTableName(),tableName);
					ajzBaseinfo.setTableName(lastTableName);
				    ajzBaseinfoService.save(newajzBaseinfo);
				    AjzRiGd realajzRiGd = ajzRiGdService.getRealajzRiGdByBaseinfo(baseinfoId);
				    if(null != realajzRiGd){
				    	ajzRigd.setId(realajzRiGd.getId());
				    }
					ajzRigd.setBaseinfoId(baseinfoId);
					ajzRiGdService.save(ajzRigd);
					successNum++;
				}
			}catch(ConstraintViolationException ex){
				failureMsg.append("<br/>单位 "+ajzRiViewgd.getEnterpriseName()+" 导入失败：");
				List<String> messageList = BeanValidators.extractPropertyAndMessageAsList(ex, ": ");
				for (String message : messageList){
					failureMsg.append(message+"; ");
					failureNum++;
				}
			}catch (Exception ex) {
				failureMsg.append("<br/>单位"+ajzRiViewgd.getEnterpriseName()+" 导入失败："+ex.getMessage());
			}
		}
		if (failureNum>0){
			failureMsg.insert(0, "，失败 "+failureNum+" 条用户，导入信息如下：");
		}
		addMessage(redirectAttributes, "已成功导入 "+successNum+" 条用户"+failureMsg);
	}
	
	/**
	 * 导入安全模板数据
	 * @param ei
	 * @param successNum
	 * @param failureNum
	 * @param failureMsg
	 * @throws InstantiationException
	 * @throws IllegalAccessException
	 */
	public void importanquan(ImportExcel ei,int successNum,int failureNum,StringBuilder failureMsg,RedirectAttributes redirectAttributes,String tableName) throws InstantiationException, IllegalAccessException{
		List<AjzViewbaseinfo> list = ei.getDataList(AjzViewbaseinfo.class);
		for (AjzViewbaseinfo ajzViewbaseinfo : list){
			Map<String, Object> map = transBean2Map(ajzViewbaseinfo);
			String tele =(String)map.get("telephone");
			if(StringUtils.isNotBlank(tele)){
				BigDecimal big = new BigDecimal(tele);
				map.put("telephone",big.toString());
			}else{
				failureNum++;
				continue;
			}
			AjzBaseinfo ajzBaseinfo= new AjzBaseinfo();
			autoAssembling(map,ajzBaseinfo);
			try{
				if (checkTelephone(ajzBaseinfo.getTelephone())){
					saveAjzBaseinfo(ajzBaseinfo,tableName);
					successNum++;
				}else{
					failureMsg.append("<br/>手机号 "+ajzBaseinfo.getTelephone()+" 已存在; ");
					failureNum++;
				}
			}catch(ConstraintViolationException ex){
				failureMsg.append("<br/>单位 "+ajzBaseinfo.getEnterpriseName()+" 导入失败：");
				List<String> messageList = BeanValidators.extractPropertyAndMessageAsList(ex, ": ");
				for (String message : messageList){
					failureMsg.append(message+"; ");
					failureNum++;
				}
			}catch (Exception ex) {
				failureMsg.append("<br/>单位"+ajzViewbaseinfo.getEnterpriseName()+" 导入失败："+ex.getMessage());
			}
		}
		if (failureNum>0){
			failureMsg.insert(0, "，失败 "+failureNum+" 条用户，导入信息如下：");
		}
		addMessage(redirectAttributes, "已成功导入 "+successNum+" 条用户"+failureMsg);
	}
	
	//储存一个新的AjzBaseinfo
	public void saveAjzBaseinfo(AjzBaseinfo ajzBaseinfo,String newTableName){
		String addr = ajzBaseinfo.getAddr();
		if(null != addr){
			HashMap<String,String> map = getPosition(addr);
			String longitude = map.get("longitude");
			String dimension = map.get("dimension");
			ajzBaseinfo.setLongitude(longitude);
			ajzBaseinfo.setDimension(dimension);
		}
		String tableName = ajzBaseinfo.getTableName();
		String lastTableName = checkTableName(tableName,newTableName);
		ajzBaseinfo.setTableName(lastTableName);
		AjzBaseinfo oldAjzBaseinfo = ajzBaseinfoService.getAjzBaseinfoByOfficeId(UserUtils.getUser().getOffice().getId());
		ajzBaseinfo.setParent(oldAjzBaseinfo);
		ajzBaseinfoService.save(ajzBaseinfo);
		saveUser(ajzBaseinfo,oldAjzBaseinfo);
		ajzBaseinfoService.save(ajzBaseinfo);
	}
	
	public static void main(String[] args) {
		HashMap<String,String> position = getPosition("福建省厦门市海沧区海沧医院");
		System.out.println(position.get("longitude"));
	}
	
	//获取经纬度
	public static HashMap<String,String> getPosition(String addr){
		byte[] bytes={};
		try {
			bytes = addr.getBytes("UTF-8");
		} catch (UnsupportedEncodingException e1) {
			e1.printStackTrace();
		}
		String newaddr= new String(bytes);
		HashMap<String,String> map = new HashMap<String, String>();
		String gaodeUrl = "http://restapi.amap.com/v3/geocode/geo?address="+newaddr+"&output=JSON&key=325c2900263796f7aa264f77dd40b303";
		try {
			URL url = new URL(gaodeUrl);
			HttpURLConnection urlConnection =(HttpURLConnection)url.openConnection();
			urlConnection.setRequestMethod("GET");
			urlConnection.connect();
			InputStream inputStream = urlConnection.getInputStream();
			JsonNode jsonNode = new ObjectMapper().readTree(inputStream);
			if(StringUtils.equals(jsonNode.findValue("status").textValue(),"1")&&StringUtils.equals(jsonNode.findValue("count").textValue(),"1")){
					String[] location = jsonNode.findValue("geocodes").findValue("location").textValue().split(",");
					map.put("longitude",location[0]);
					map.put("dimension",location[1]);
				return map;
			}
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return map;
	}
	
	/**
	 *保存一个user
	 */
	public void saveUser(AjzBaseinfo ajzBaseinfo,AjzBaseinfo oldAjzBaseinfo){
		User user = new User();
		User loginUser = UserUtils.getUser();
		Office currentOffice = officeService.get(oldAjzBaseinfo.getBackUpa());
		Office anotherOffice = ajzBaseinfoService.getAnoterOffice(currentOffice);
		user.setLoginName(ajzBaseinfo.getTelephone());
		user.setName(ajzBaseinfo.getChargePerson());
		user.setCompany(loginUser.getCompany());
		user.setOffice(anotherOffice);
		user.setPassword(systemService.entryptPassword("123456"));
		user.setRemarks(ajzBaseinfo.getId());
		user.setMobile(ajzBaseinfo.getTelephone());
		user.setCorpName(ajzBaseinfo.getEnterpriseName());
		String addr = ajzBaseinfo.getAddr();
		if(null != addr){
			user.setAddress(addr);
		}
		// 角色数据有效性验证，过滤不在授权内的角色
		List<Role> roleList = Lists.newArrayList();
		List<String> roleIdList = loginUser.getRoleIdList();
		for (Role r : systemService.findAllRole()){
			if (roleIdList.contains(r.getId())){
				roleList.add(r);
			}
		}
		user.setRoleList(roleList);
		user.setNo(ajzBaseinfo.getId());
		systemService.saveUser(user);//save user
		ajzBaseinfo.setBackUpb(user.getId());//给baseinfo存放userID
	}
	
	/**
	 * 检查表名
	 * @return
	 */
	public String checkTableName(String oldTableName,String newTableName){
		StringBuilder builder = new StringBuilder();
		if(StringUtils.isBlank(oldTableName)){
			builder.append(newTableName);
		}else if(StringUtils.isNoneBlank(oldTableName)){
			if(oldTableName.indexOf(newTableName)<0){
				builder.append(","+newTableName);
			}
		}
		return builder.toString();
	}
	
	/**
	 * 将参数自动装配到Object中
	 * @return
	 */
	public void autoAssembling(Map<String,Object> map,Object obj){
		Class targetClass =obj.getClass();
		Field[] fields = targetClass.getDeclaredFields();
		for(Field field:fields){
			for(Map.Entry<String,Object> entity:map.entrySet()){
				String key = entity.getKey();
				if(field.getName().equals(key)){
					try {
						field.setAccessible(true);
						field.set(obj,entity.getValue());
					} catch (IllegalArgumentException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					} catch (IllegalAccessException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
					
				}
			}
		}
	}
	
	/**
	 * 将bean转化成map
	 * @param obj
	 * @return
	 */
	public static Map<String, Object> transBean2Map(Object obj) {  
	    if (obj == null) {  
	        return null;  
	    }  
	    Map<String, Object> map = new HashMap<String, Object>();  
	    try {  
	        BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());  
	        PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();  
	        for (PropertyDescriptor property : propertyDescriptors) {  
	            String key = property.getName();  
	            // 过滤class属性  
	            if (!key.equals("class")) {  
	                // 得到property对应的getter方法  
	                Method getter = property.getReadMethod();  
	                Object value = getter.invoke(obj);  
	                map.put(key, value);  
	            }  
	        }  
	    } catch (Exception e) {  
	    	e.printStackTrace();
	    }  
	    return map;  
	  
	}  
	
	/*
	 * 检查电话是否已存在
	 */
	public boolean checkTelephone(String telephone){
		User user = systemService.getUserByLoginName(telephone);
		if(null == user){
			return true;
		}
		return false;
	}
	
	/**
	 * 安全模板
	 * @param request
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "import/shipinTemplate")
	public String shipinTemplate(HttpServletRequest request,HttpServletResponse response,RedirectAttributes redirectAttributes){
			try {
	            String fileName = "食品安全数据导入模板.xlsx";
	            String realPath = request.getSession().getServletContext().getRealPath("WEB-INF/views/downLoad/食品检查.xlsx");
	            downLoadFile(realPath,response,fileName);
	    		return null;
			} catch (Exception e) {
				addMessage(redirectAttributes, "导入模板下载失败！失败信息："+e.getMessage());
			}
	return "redirect:" + adminPath + "/ajz/ajzBaseinfo/list?repage";	
	}
	
	
	
	/**
	 * 安全模板
	 * @param request
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "import/anquanTemplate")
	public String anquanTemplate(HttpServletRequest request,HttpServletResponse response,RedirectAttributes redirectAttributes){
			try {
	            String fileName = "安全生产数据导入模板.xlsx";
	            String realPath = request.getSession().getServletContext().getRealPath("WEB-INF/views/downLoad/安全生产.xlsx");
	            downLoadFile(realPath,response,fileName);
	    		return null;
			} catch (Exception e) {
				addMessage(redirectAttributes, "导入模板下载失败！失败信息："+e.getMessage());
			}
	return "redirect:" + adminPath + "/ajz/ajzBaseinfo/list?repage";	
	}
	
	/**
	 * 消防出租屋
	 * @param request
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "import/xfczwTemplate")
	public String xfczwTemplate(HttpServletRequest request,HttpServletResponse response,RedirectAttributes redirectAttributes){
		try {
            String fileName = "消防出租屋数据导入模板.xlsx";
            String realPath = request.getSession().getServletContext().getRealPath("WEB-INF/views/downLoad/消防出租屋.xlsx");
            downLoadFile(realPath,response,fileName);
    		return null;
		} catch (Exception e) {
			addMessage(redirectAttributes, "导入模板下载失败！失败信息："+e.getMessage());
		}
	return "redirect:" + adminPath + "/ajz/ajzBaseinfo/list?repage";	
	}
	
	/**
	 * 消防门店
	 * @param request
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "import/xfdmTemplate")
	public String xfdmTemplate(HttpServletRequest request,HttpServletResponse response,RedirectAttributes redirectAttributes){
		try {
            String fileName = "消防门店数据导入模板.xlsx";
            String realPath = request.getSession().getServletContext().getRealPath("WEB-INF/views/downLoad/店面基础排查表.xlsx");
            downLoadFile(realPath,response,fileName);
    		return null;
		} catch (Exception e) {
			addMessage(redirectAttributes, "导入模板下载失败！失败信息："+e.getMessage());
		}
	return "redirect:" + adminPath + "/ajz/ajzBaseinfo/list?repage";	
	}
	
	
	
	/**
	 * 燃气管道
	 * @param request
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "import/rqgdTemplate")
	public String rqgdTemplate(HttpServletRequest request,HttpServletResponse response,RedirectAttributes redirectAttributes){
		try {
            String fileName = "燃气管道数据导入模板.xlsx";
            String realPath = request.getSession().getServletContext().getRealPath("WEB-INF/views/downLoad/管道燃气安全检查.xlsx");
            downLoadFile(realPath,response,fileName);
    		return null;
		} catch (Exception e) {
			addMessage(redirectAttributes, "导入模板下载失败！失败信息："+e.getMessage());
		}
	return "redirect:" + adminPath + "/ajz/ajzBaseinfo/list?repage";	
	}
	
	/**
	 * 燃气钢化
	 * @param request
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "import/rqghTemplate")
	public String rqghTemplate(HttpServletRequest request,HttpServletResponse response,RedirectAttributes redirectAttributes){
		try {
            String fileName = "燃气液化石油数据导入模板.xlsx";
            String realPath = request.getSession().getServletContext().getRealPath("WEB-INF/views/downLoad/液化石油安全检查.xlsx");
            downLoadFile(realPath,response,fileName);
    		return null;
		} catch (Exception e) {
			addMessage(redirectAttributes, "导入模板下载失败！失败信息："+e.getMessage());
		}
	return "redirect:" + adminPath + "/ajz/ajzBaseinfo/list?repage";	
	}
	
	/*
	 * 根据经纬度获取地址
	 */
	public  String getPositionAddr(HashMap<String,String> map){
		String str ="http://restapi.amap.com/v3/geocode/regeo?output=JSON&location="+map.get("lng")+","+map.get("lat")+"&key=325c2900263796f7aa264f77dd40b303";
		try {
			URL url = new URL(str);
			HttpURLConnection connection =(HttpURLConnection)url.openConnection();
			connection.setRequestMethod("GET");
			connection.connect();
			InputStream inputStream = connection.getInputStream();
			JsonNode jsonNode = new ObjectMapper().readTree(inputStream);
			System.out.println(jsonNode);
			if(StringUtils.equals(jsonNode.findValue("status").textValue(),"1")){
				return jsonNode.findValue("regeocode").findValue("formatted_address").textValue();
			}
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return null;
	}
	
	/*
	 * 给门店添加经纬度
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "addAjzBaseinfo")
	public void addAjzBaseinfo(HttpServletRequest request,HttpServletResponse response){
		HashMap<String,String> parameter = getParameter(request);
		HashMap<String,String> message = new HashMap<String,String>();
		AjzBaseinfo ajzBaseinfo = ajzBaseinfoService.get(parameter.get("ajzBaseinfoId"));
		ajzBaseinfo.setDimension(parameter.get("lat"));
		ajzBaseinfo.setLongitude(parameter.get("lng"));
		String addr = getPositionAddr(parameter);
		if(StringUtils.isNotBlank(addr)){
			ajzBaseinfo.setAddr(addr);
		}
		ajzBaseinfoService.save(ajzBaseinfo);
		message.put("info","success");
		backMessage(response,message);
		}
	
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "index")
	public String index(Model model) {
		return "modules/ajz/ajzBaseinfoIndex";
	}
	
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "none")
	public String none(AjzBaseinfo ajzBaseinfo, HttpServletRequest request, HttpServletResponse response, Model model) {
		HashMap<String,String> parameter = getParameter(request);
		String ajzBaseinfoId = parameter.get("ajzBaseinfo.id");
		if(StringUtils.isNoneBlank(ajzBaseinfoId) && !"".equals(ajzBaseinfoId)){
			request.setAttribute("ajzBaseinfoId",ajzBaseinfoId);
			AjzBaseinfo baseinfo = ajzBaseinfoService.get(ajzBaseinfoId);
			List<AjzBaseinfo> ajzBaseinfoList = ajzBaseinfoService.findChildList(baseinfo);
			if(StringUtils.isNoneBlank(baseinfo.getDimension())&&StringUtils.isNoneBlank(baseinfo.getLongitude())){
				ajzBaseinfoList.add(baseinfo);
			}
			StringWriter ajzBaseinfoJson = Message2Json(ajzBaseinfoList);
			request.setAttribute("ajzBaseinfoList",ajzBaseinfoJson);
		}
		return "modules/ajz/ajzBaseinfoNone";
	}
	
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value ="tree")
	public String tree(AjzBaseinfo ajzBaseinfo, HttpServletRequest request, HttpServletResponse response, Model model) {
		AjzBaseinfo currentAjzBaseinfo = ajzBaseinfoService.getAjzBaseinfoByOfficeId(UserUtils.getUser().getOffice().getId());
		if(null != currentAjzBaseinfo&&!UserUtils.getUser().isAdmin()){
		  ajzBaseinfo=currentAjzBaseinfo;
		}
		request.setAttribute("ajzBaseinfoList",ajzBaseinfoService.findBaseinfoChildList(ajzBaseinfo));
		return "modules/ajz/ajzBaseinfoTree";
	}
	
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = {"list", ""})
	public String list(AjzBaseinfo ajzBaseinfo, HttpServletRequest request, HttpServletResponse response, Model model) {
		AjzBaseinfo currentAjzBaseinfo = ajzBaseinfoService.getAjzBaseinfoByOfficeId(UserUtils.getUser().getOffice().getId());
		if(null != currentAjzBaseinfo&&!UserUtils.getUser().isAdmin()){
			  ajzBaseinfo=currentAjzBaseinfo;
			}
		List<AjzBaseinfo> list = ajzBaseinfoService.findBaseinfoChildList(ajzBaseinfo); 
		model.addAttribute("list", list);
		return "modules/ajz/ajzBaseinfoList";
	}

	@RequestMapping(value = "form")
	public String form(AjzBaseinfo ajzBaseinfo, Model model) {
		if (ajzBaseinfo.getParent()!=null && StringUtils.isNotBlank(ajzBaseinfo.getParent().getId())){
			ajzBaseinfo.setParent(ajzBaseinfoService.get(ajzBaseinfo.getParent().getId()));
			// 获取排序号，最末节点排序号+30
			if (StringUtils.isBlank(ajzBaseinfo.getId())){
				AjzBaseinfo ajzBaseinfoChild = new AjzBaseinfo();
				ajzBaseinfoChild.setParent(new AjzBaseinfo(ajzBaseinfo.getParent().getId()));
				List<AjzBaseinfo> list = ajzBaseinfoService.findList(ajzBaseinfo); 
				if (list.size() > 0){
					ajzBaseinfo.setSort(list.get(list.size()-1).getSort());
					if (ajzBaseinfo.getSort() != null){
						ajzBaseinfo.setSort(ajzBaseinfo.getSort() + 30);
					}
				}
			}
		}
		if (ajzBaseinfo.getSort() == null){
			ajzBaseinfo.setSort(30);
		}
		List<Dict> gasCompanyList = ajzBaseinfoService.findSelectList("gas_company");
		List<Dict> placeCategoryList = ajzBaseinfoService.findSelectList("place_category");
		List<Dict> fireAuditList = ajzBaseinfoService.findSelectList("fire_audit");
		List<Dict> gasPropertyList = ajzBaseinfoService.findSelectList("gas_property");
		List<Dict> gasTypeList = ajzBaseinfoService.findSelectList("gas_type");
		List<Dict> purchaseVoucherList = ajzBaseinfoService.findSelectList("purchase_voucher");
		String baseinfoId = ajzBaseinfo.getId();
		setBaseTypeToModel(baseinfoId,model);
		model.addAttribute("placeCategoryList",placeCategoryList);
		model.addAttribute("gasCompanyList",gasCompanyList);
		model.addAttribute("ajzBaseinfo", ajzBaseinfo);
		model.addAttribute("jsonajzBaseinfo",Message2Json(ajzBaseinfo));
		model.addAttribute("fireAuditList",fireAuditList);
		model.addAttribute("gasPropertyList",gasPropertyList);
		model.addAttribute("gasTypeList", gasTypeList);
		model.addAttribute("purchaseVoucherList",purchaseVoucherList);
		return "modules/ajz/ajzBaseinfoForm";
	}
	
	//判断类型表是否放入model中
	public void setBaseTypeToModel(String baseinfoId,Model model){
		AjzXfCzw ajzXfCzw = ajzXfCzwService.getRealAjzXfCzwByBaseinfo(baseinfoId);
		AjzXfDm  ajxXfDm = ajzXfDmService.getRealAjzXfDmByBaseinfoId(baseinfoId);
		AjzRiGd  ajzRiGd = ajzRiGdService.getRealajzRiGdByBaseinfo(baseinfoId);
		AjzRiGh  ajzRiGh = ajzRiGhService.getRealAjzRiGhByBaseinfoId(baseinfoId);
		model.addAttribute("ajzXfCzw",Message2Json(ajzXfCzw));
		model.addAttribute("ajxXfDm", Message2Json(ajxXfDm));		
		model.addAttribute("ajzRiGd", Message2Json(ajzRiGd));	
		model.addAttribute("ajzRiGh", Message2Json(ajzRiGh));	
	}

	@RequiresPermissions("ajz:ajzBaseinfo:edit")
	@RequestMapping(value = "save")
	public String save(AjzBaseinfo ajzBaseinfo, Model model, RedirectAttributes redirectAttributes,HttpServletRequest request) {
		Map<String,String> param = getParameter(request);
		AjzBaseinfo oldAjzBaseinfo=null;
		if(StringUtils.isNotBlank(param.get("parentId"))&&!StringUtils.equals("0",param.get("parentId"))){
			oldAjzBaseinfo=ajzBaseinfoService.get(param.get("parentId"));
		}else{
			oldAjzBaseinfo = ajzBaseinfoService.getAjzBaseinfoByOfficeId(UserUtils.getUser().getOffice().getId());
		}
		if(StringUtils.isBlank(ajzBaseinfo.getTelephone())){
			addMessage(model,"手机号不能为空");
			return form(ajzBaseinfo, model);
		}
		if(StringUtils.isBlank(ajzBaseinfo.getChargePerson())){
			addMessage(model,"负责人不能为空");
			return form(ajzBaseinfo, model);
		}
		if(StringUtils.isBlank(ajzBaseinfo.getBackUpc())){
			addMessage(model,"邮箱不能为空");
			return form(ajzBaseinfo, model);
		}
		if(StringUtils.isBlank(ajzBaseinfo.getId())){
			ajzBaseinfo.setParent(oldAjzBaseinfo);
		}
		if (!beanValidator(model, ajzBaseinfo)){
			return form(ajzBaseinfo, model);
		}
		setBaseinfoTableName(param,ajzBaseinfo);//添加表名
		ajzBaseinfoService.save(ajzBaseinfo);//储存baseinfo
		User user = ajzBaseinfoService.getRealSysUserByTelephone(ajzBaseinfo.getTelephone());
		User idUser = ajzBaseinfoService.getRealSysUserById(ajzBaseinfo.getBackUpb());//通过id获取user
		//储存user
		if(null == idUser){
			User loginUser = UserUtils.getUser();
			if(null != user){
				addMessage(model,"手机号已存在");
				return form(ajzBaseinfo, model);
			}else{
				idUser = new User();
			}
			Office currentOffice = officeService.get(oldAjzBaseinfo.getBackUpa());
			Office anotherOffice = ajzBaseinfoService.getAnoterOffice(currentOffice);
			idUser.setLoginName(ajzBaseinfo.getTelephone());
			idUser.setEmail(ajzBaseinfo.getBackUpc());
			idUser.setName(ajzBaseinfo.getChargePerson());
			idUser.setCompany(loginUser.getCompany());
			idUser.setOffice(anotherOffice);
			idUser.setPassword(systemService.entryptPassword("123456"));
			idUser.setRemarks(ajzBaseinfo.getId());
			idUser.setNo(ajzBaseinfo.getId());
			idUser.setMobile(ajzBaseinfo.getTelephone());
			idUser.setCorpName(ajzBaseinfo.getEnterpriseName());
			String addr = ajzBaseinfo.getAddr();
			if(null != addr){
				idUser.setAddress(addr);
			}
			// 角色数据有效性验证，过滤不在授权内的角色
			List<Role> roleList = Lists.newArrayList();
			List<String> roleIdList = loginUser.getRoleIdList();
			for (Role r : systemService.findAllRole()){
				if (roleIdList.contains(r.getId())){
					roleList.add(r);
				}
			}
			idUser.setRoleList(roleList);
			idUser.setNo(ajzBaseinfo.getId());
			systemService.saveUser(idUser);
		}else {
			if(!StringUtils.equals(idUser.getLoginName(),ajzBaseinfo.getTelephone())){
				idUser.setLoginName(ajzBaseinfo.getTelephone());
			}
			idUser.setEmail(ajzBaseinfo.getBackUpc());
			idUser.setRemarks(ajzBaseinfo.getId());
			idUser.setName(ajzBaseinfo.getChargePerson());
			idUser.setMobile(ajzBaseinfo.getTelephone());
			idUser.setCorpName(ajzBaseinfo.getEnterpriseName());
			String addr = ajzBaseinfo.getAddr();
			if(null != addr){
				idUser.setAddress(addr);
			}
			idUser.setNo(ajzBaseinfo.getId());
			systemService.update(idUser);;//save user
		}
		if(StringUtils.isNoneBlank(ajzBaseinfo.getAddr())){
			HashMap<String,String> position = getPosition(ajzBaseinfo.getAddr());
			ajzBaseinfo.setLongitude(position.get("longitude"));
			ajzBaseinfo.setDimension(position.get("dimension"));
		}
		ajzBaseinfo.setBackUpb(idUser.getId());
		ajzBaseinfoService.save(ajzBaseinfo);
		setBaseType(param,ajzBaseinfo.getId());//判断是否产出或者添加类
		addMessage(redirectAttributes, "保存门店区域划分表成功");
		return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/?repage";
	}
	
	/*
	 * 给ajzBaseinfo添加表名
	 */
	public void setBaseinfoTableName(Map<String,String> map,AjzBaseinfo ajzBaseinfo){
		String xfcz =map.get("xfczid");
		String xfdmid =map.get("xfdmid");
		String rqgdid =map.get("rqgdid");
		String rqghid =map.get("rqghid");
		String shipinid =map.get("shipinid");
		String securProductid =map.get("securProductid");
		StringBuffer buffer = new StringBuffer();
		if(StringUtils.equals(xfcz, "1")){
			buffer.append(","+XFCZWTABLENAME);
				}
		if(StringUtils.equals(xfdmid, "1")){
			buffer.append(","+XFDMTABLENAME);		
				}
		if(StringUtils.equals(rqgdid, "1")){
			buffer.append(","+RQGDTABLENAME);
		}
		if(StringUtils.equals(rqghid, "1")){
			buffer.append(","+RQGHTABLENAME);
		}
		if(StringUtils.equals(shipinid, "1")){
			buffer.append(","+SPTABLENAME);
		}
		if(StringUtils.equals(securProductid, "1")){
			buffer.append(","+AQTABLENAME);
		}
		String tableName="";
		if(buffer.length()>=1){
			  tableName = buffer.substring(1);
		}
		ajzBaseinfo.setTableName(tableName);
	}
	
	//判断表是否储存或者删除
	public void setBaseType(Map<String,String> map,String baseinfoId){
		String xfcz =map.get("xfczid");
		String xfdmid =map.get("xfdmid");
		String rqgdid =map.get("rqgdid");
		String rqghid =map.get("rqghid");
		AjzXfCzw ajzXfCzw = ajzXfCzwService.getAjzXfCzwByBaseinfo(baseinfoId);
		AjzXfDm  ajxXfDm = ajzXfDmService.getAjzXfDmByBaseinfoId(baseinfoId);
		AjzRiGd  ajzRiGd = ajzRiGdService.getajzRiGdByBaseinfo(baseinfoId);
		AjzRiGh  ajzRiGh = ajzRiGhService.getAjzRiGhByBaseinfoId(baseinfoId);
		if(StringUtils.equals("1", xfcz)){
			if(null == ajzXfCzw){
				ajzXfCzw = new AjzXfCzw(); 
			}
			setAjzXfCzwParam(map,ajzXfCzw,baseinfoId);
			ajzXfCzwService.save(ajzXfCzw);
		}else{
			ajzXfCzwService.delete(ajzXfCzw);
		}
		
		if(StringUtils.equals("1", xfdmid)){
			if(null == ajxXfDm){
				ajxXfDm = new AjzXfDm(); 
			}
			setAjzXfDmParam(map,ajxXfDm,baseinfoId);
			ajzXfDmService.save(ajxXfDm);
		}else{
			ajzXfDmService.delete(ajxXfDm);
		}
		
		if(StringUtils.equals("1", rqgdid)){
			if(null == ajzRiGd){
				ajzRiGd = new AjzRiGd(); 
			}
			setAjzRiGdParam(map,ajzRiGd,baseinfoId);
			ajzRiGdService.save(ajzRiGd);
		}else{
			ajzRiGdService.delete(ajzRiGd);
		}
		
		if(StringUtils.equals("1", rqghid)){
			if(null == ajzRiGh){
				ajzRiGh = new AjzRiGh(); 
			}
			setAjzRiGhParam(map,ajzRiGh,baseinfoId);
			ajzRiGhService.save(ajzRiGh);
		}else{
			ajzRiGhService.delete(ajzRiGh);
		}
		
	}
	
	//给AjzXfCzw存值
	public void setAjzXfCzwParam(Map<String,String> map ,AjzXfCzw ajzXfCzw,String baseinfoId){
		ajzXfCzw.setBaseinfoId(baseinfoId);
		ajzXfCzw.setDelFlag("0");
		ajzXfCzw.setArea(map.get("area"));
		ajzXfCzw.setFloorNumber(map.get("floorNumber"));
		ajzXfCzw.setPersonNumber(map.get("personNumber"));
		ajzXfCzw.setPlateNumber(map.get("plateNumber"));
	}

	//给AjzXfDm存值
	public void setAjzXfDmParam(Map<String,String> map ,AjzXfDm ajzXfDm,String baseinfoId){
		ajzXfDm.setBaseinfoId(baseinfoId);
		ajzXfDm.setDelFlag("0");
		ajzXfDm.setPlaceName(map.get("placeName"));
		ajzXfDm.setArchitectureName(map.get("architectureName"));
		ajzXfDm.setArea(map.get("area"));
		ajzXfDm.setBusinessLicense(map.get("businessLicense"));
		ajzXfDm.setFireAudit(map.get("fireAudit"));
		ajzXfDm.setPlaceCategory(map.get("placeCategory"));
		ajzXfDm.setPlateNumber(map.get("plateNumber"));
	}
	
	//给AjzRiGd存值
	public void setAjzRiGdParam(Map<String,String> map ,AjzRiGd ajzRiGd,String baseinfoId){
		ajzRiGd.setBaseinfoId(baseinfoId);
		ajzRiGd.setDelFlag("0");
		ajzRiGd.setBusinessLicense(map.get("businessLicense"));
		ajzRiGd.setGasProperty(map.get("gasProperty"));
		ajzRiGd.setIdCard(map.get("idCard"));
		ajzRiGd.setTableNumber(map.get("gdtableNumber"));
	}
	
	//给AjzRiGh存值
	public void setAjzRiGhParam(Map<String,String> map ,AjzRiGh ajzRiGh,String baseinfoId){
		ajzRiGh.setBaseinfoId(baseinfoId);
		ajzRiGh.setDelFlag("0");
		ajzRiGh.setTableNumber(map.get("ghtableNumber"));
		ajzRiGh.setStoreName(map.get("storeName"));
		ajzRiGh.setBusinessLicense(map.get("businessLicense"));
		ajzRiGh.setOutdoorSign(map.get("outdoorSign"));
		ajzRiGh.setGasCompany(map.get("gasCompany"));
		ajzRiGh.setGasNumber(map.get("gasNumber"));
		ajzRiGh.setGasType(map.get("gasType"));
		ajzRiGh.setGasProperty(map.get("gasProperty"));
		ajzRiGh.setGasBottleNumber(map.get("gasBottleNumber"));
		ajzRiGh.setPurchaseVoucher(map.get("purchaseVoucher"));
		ajzRiGh.setBackUpa(map.get("backUpa"));
	}
	
	@RequiresPermissions("ajz:ajzBaseinfo:edit")
	@RequestMapping(value = "delete")
	public String delete(AjzBaseinfo ajzBaseinfo, RedirectAttributes redirectAttributes) {
		ajzBaseinfoService.delete(ajzBaseinfo);
		User user = systemService.getUserByLoginName(ajzBaseinfo.getTelephone());
		if(null != user){
			systemService.deleteUser(user);
		}
		addMessage(redirectAttributes, "删除门店区域划分表成功");
		return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/?repage";
	}

	@RequiresPermissions("user")
	@ResponseBody
	@RequestMapping(value = "treeData")
	public List<Map<String, Object>> treeData(@RequestParam(required=false) String extId, HttpServletResponse response) {
		List<Map<String, Object>> mapList = Lists.newArrayList();
		List<AjzBaseinfo> list = ajzBaseinfoService.findList(new AjzBaseinfo());
		for (int i=0; i<list.size(); i++){
			AjzBaseinfo e = list.get(i);
			if (StringUtils.isBlank(extId) || (extId!=null && !extId.equals(e.getId()) && e.getParentIds().indexOf(","+extId+",")==-1)){
				Map<String, Object> map = Maps.newHashMap();
				map.put("id", e.getId());
				map.put("pId", e.getParentId());
				map.put("name", e.getEnterpriseName());
				mapList.add(map);
			}
		}
		return mapList;
	}
	
	/*
	 * 跳转消防店面
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "indexXfDm")
	public String indexXfDm(Model model) {
		return "modules/ajz/ajzXfDmIndex";
	}
	/*
	 * 跳转消防出租屋
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "indexXfCzw")
	public String indexXfCzw(Model model) {
		return "modules/ajz/ajzXfCzwIndex";
	}
	/*
	 * 跳转燃气管道
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "indexRiGd")
	public String indexRiGd(Model model) {
		return "modules/ajz/ajzRiGdIndex";
	}
	/*
	 * 跳转燃气钢化
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "indexRiGh")
	public String indexRiGh(Model model) {
		return "modules/ajz/ajzRiGhIndex";
	}
	/*
	 * 跳转食品
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "indexSp")
	public String indexSP(Model model) {
		return "modules/ajz/ajzSPIndex";
	}
	/*
	 * 跳转安全生产
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "indexAqsc")
	public String indexSpAq(Model model) {
		return "modules/ajz/ajzAqscIndex";
	}
	
	/*
	 * 获取食品的树list
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value ="spTree")
	public String spTree(AjzBaseinfo ajzBaseinfo, HttpServletRequest request, HttpServletResponse response, Model model){
		AjzBaseinfo currentAjzBaseinfo = ajzBaseinfoService.getAjzBaseinfoByOfficeId(UserUtils.getUser().getOffice().getId());
		if(null != currentAjzBaseinfo&&!UserUtils.getUser().isAdmin()){
			 ajzBaseinfo=currentAjzBaseinfo;
		}
		request.setAttribute("ajzBaseinfoList",ajzBaseinfoService.findBaseinfoSpChildList(ajzBaseinfo));
		return "modules/ajz/ajzSpTree";
	}
	
	/*
	 * 获取安全生产的树list
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value ="aqscTree")
	public String spaqTree(AjzBaseinfo ajzBaseinfo, HttpServletRequest request, HttpServletResponse response, Model model){
		AjzBaseinfo currentAjzBaseinfo = ajzBaseinfoService.getAjzBaseinfoByOfficeId(UserUtils.getUser().getOffice().getId());
		if(null != currentAjzBaseinfo&&!UserUtils.getUser().isAdmin()){
			 ajzBaseinfo=currentAjzBaseinfo;
		}
		request.setAttribute("ajzBaseinfoList",ajzBaseinfoService.findBaseinfoSpaqChildList(ajzBaseinfo));
		return "modules/ajz/ajzAqscTree";
	}
	
	/*
	 * 获取店面的树list
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value ="XfDmtree")
	public String XfDmtree(AjzBaseinfo ajzBaseinfo, HttpServletRequest request, HttpServletResponse response, Model model){
		AjzBaseinfo currentAjzBaseinfo = ajzBaseinfoService.getAjzBaseinfoByOfficeId(UserUtils.getUser().getOffice().getId());
		if(null != currentAjzBaseinfo&&!UserUtils.getUser().isAdmin()){
			 ajzBaseinfo=currentAjzBaseinfo;
		}
		request.setAttribute("ajzBaseinfoList",ajzBaseinfoService.findBaseinfoXfDmChildList(ajzBaseinfo));
		return "modules/ajz/ajzXfDmTree";
	}
	
	/*
	 * 获取消防出租屋店面的树list
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value ="XfCzwtree")
	public String XfCzwtree(AjzBaseinfo ajzBaseinfo, HttpServletRequest request, HttpServletResponse response, Model model){
		AjzBaseinfo currentAjzBaseinfo = ajzBaseinfoService.getAjzBaseinfoByOfficeId(UserUtils.getUser().getOffice().getId());
		if(null != currentAjzBaseinfo&&!UserUtils.getUser().isAdmin()){
			 ajzBaseinfo=currentAjzBaseinfo;
		}
		request.setAttribute("ajzBaseinfoList",ajzBaseinfoService.findBaseinfoXfCzwChildList(ajzBaseinfo));
		return "modules/ajz/ajzXfCzwTree";
	}
	
	/*
	 * 获取燃气钢化的树list
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value ="RiGhtree")
	public String riGhtree(AjzBaseinfo ajzBaseinfo, HttpServletRequest request, HttpServletResponse response, Model model){
		AjzBaseinfo currentAjzBaseinfo = ajzBaseinfoService.getAjzBaseinfoByOfficeId(UserUtils.getUser().getOffice().getId());
		if(null != currentAjzBaseinfo&&!UserUtils.getUser().isAdmin()){
			 ajzBaseinfo=currentAjzBaseinfo;
		}
		request.setAttribute("ajzBaseinfoList",ajzBaseinfoService.findBaseinfoRiGhChildList(ajzBaseinfo));
		return "modules/ajz/ajzRiGhTree";
	}
	
	/*
	 * 获取燃气管道的树list
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value ="RiGdtree")
	public String riGdtree(AjzBaseinfo ajzBaseinfo, HttpServletRequest request, HttpServletResponse response, Model model){
		AjzBaseinfo currentAjzBaseinfo = ajzBaseinfoService.getAjzBaseinfoByOfficeId(UserUtils.getUser().getOffice().getId());
		if(null != currentAjzBaseinfo&&!UserUtils.getUser().isAdmin()){
			 ajzBaseinfo=currentAjzBaseinfo;
		}
		request.setAttribute("ajzBaseinfoList",ajzBaseinfoService.findBaseinfoRiGdChildList(ajzBaseinfo));
		return "modules/ajz/ajzRiGdTree";
	}
	
	/*------------------------------------------安全生产----------------------------------------------*/
	
	/*
	 * 安全生产List
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "aqscNone")
	public String aqscNone(AjzRecord ajzRecord,HttpServletRequest request, HttpServletResponse response, Model model){
		HashMap<String,String> param = getParameter(request);
		String ajzBaseinfoId = param.get("ajzBaseinfo.id");
		if(StringUtils.isNotBlank(ajzBaseinfoId)){
			AjzBaseinfo ajzBaseinfoByid = ajzBaseinfoService.get(ajzBaseinfoId);
			if(StringUtils.isNotBlank(ajzBaseinfoByid.getEnterpriseName())){
				ajzRecord.setAjzBaseinfoId(ajzBaseinfoId);
			}else{
				ajzRecord.setBackup2(ajzBaseinfoByid.getId());
			}
		}
		User loginUser = UserUtils.getUser();
		if(!loginUser.isAdmin()){
			AjzBaseinfo ajzBaseinfo = ajzBaseinfoService.getAjzBaseinfoByOfficeId(loginUser.getOffice().getId());
			ajzRecord.setBackup2(ajzBaseinfo.getId());
		}
		ajzRecord.setType("ajz_aqsc");
		Page<AjzRecord> page = ajzRecordService.findRealAjzRecordPageByBaseinfoId(new Page<AjzRecord>(request, response), ajzRecord); 
		model.addAttribute("page", page);
		model.addAttribute("ajzBaseinfoId",ajzBaseinfoId);
		return "modules/ajz/ajzAqscRecordList";
	}
	
	//获取安全生产的隐患内容
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "aqscform")
	public String aqscform(AjzRecord ajzRecord, Model model,HttpServletRequest request,RedirectAttributes redirectAttributes) {
		HashMap<String,String> param = getParameter(request);
		String baseinfoId = param.get("ajzBaseinfoId");
		if(StringUtils.isNotBlank(baseinfoId)){
			AjzBaseinfo ajzBaseinfoByid = ajzBaseinfoService.get(baseinfoId);
			if(StringUtils.isBlank(ajzBaseinfoByid.getEnterpriseName())){
				addMessage(redirectAttributes, "请选择门店");
				return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/aqscNone";
			}
		}else if(StringUtils.isBlank(param.get("recordId"))){
			addMessage(redirectAttributes, "请选择门店");
			return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/aqscNone";
		}
		if(StringUtils.isNotBlank(param.get("recordId"))){
			ajzRecord = ajzRecordService.get(param.get("recordId"));
			baseinfoId = ajzRecord.getAjzBaseinfoId();
		}
		AjzBaseinfo ajzBaseinfo = ajzBaseinfoService.get(baseinfoId);
		model.addAttribute("ajzBaseinfo", ajzBaseinfo);
		model.addAttribute("ajzRecord", ajzRecord);
		return "modules/ajz/ajzAqscRecordForm";
	}
	
	/*
	 * 删除安全生产隐患点
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:edit")
	@RequestMapping(value = "deleteAqsc")
	public String deleteAqsc(Model model,HttpServletRequest request,RedirectAttributes redirectAttributes){
		HashMap<String,String> param = getParameter(request);
		AjzRecord ajzRecord = ajzRecordService.get(param.get("recordId"));
		String ajzBaseinfoId = ajzRecord.getAjzBaseinfoId();
		ajzRecordService.delete(ajzRecord);
		return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/aqscNone?ajzBaseinfo.id="+ajzBaseinfoId+"";
	}
	
	/**
	 * 保存安全生产记录表
	 * @param ajzRecord
	 * @param model
	 * @param request
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "saveAqscRecord")
	public String saveAqscRecord(AjzRecord ajzRecord,Model model,HttpServletRequest request,RedirectAttributes redirectAttributes){
		if (!beanValidator(model, ajzRecord)){
			return aqscform(ajzRecord, model,request,redirectAttributes);
		}
		AjzBaseinfo ajzBaseinfo = ajzBaseinfoService.get(ajzRecord.getAjzBaseinfoId());
		ajzRecord.setBackup2(ajzBaseinfo.getParentId());
		ajzRecord.setType("ajz_aqsc");
		ajzRecordService.save(ajzRecord);
		addMessage(redirectAttributes, "保存安全生产表成功");
		return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/aqscNone?ajzBaseinfo.id="+ajzRecord.getAjzBaseinfoId()+"";
	}
	
	/*-----------------------------------------------食品安全------------------------------------------------------*/
	
	/*
	 *食品List
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "spNone")
	public String spNone(AjzRecord ajzRecord,HttpServletRequest request, HttpServletResponse response, Model model){
		HashMap<String,String> param = getParameter(request);
		String ajzBaseinfoId = param.get("ajzBaseinfo.id");
		if(StringUtils.isNotBlank(ajzBaseinfoId)){
			AjzBaseinfo ajzBaseinfoByid = ajzBaseinfoService.get(ajzBaseinfoId);
			if(StringUtils.isNotBlank(ajzBaseinfoByid.getEnterpriseName())){
				ajzRecord.setAjzBaseinfoId(ajzBaseinfoId);
			}else{
				ajzRecord.setBackup2(ajzBaseinfoByid.getId());
			}
		}
		User loginUser = UserUtils.getUser();
		if(!loginUser.isAdmin()){
			AjzBaseinfo ajzBaseinfo = ajzBaseinfoService.getAjzBaseinfoByOfficeId(loginUser.getOffice().getId());
			ajzRecord.setBackup2(ajzBaseinfo.getId());
		}
		ajzRecord.setType("ajz_sp");
		Page<AjzRecord> page = ajzRecordService.findRealAjzRecordPageByBaseinfoId(new Page<AjzRecord>(request, response), ajzRecord); 
		model.addAttribute("page", page);
		model.addAttribute("ajzBaseinfoId",ajzBaseinfoId);
		return "modules/ajz/ajzSpRecordList";
	}
	
	//获取食品的隐患内容
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "spform")
	public String spform(AjzRecord ajzRecord, Model model,HttpServletRequest request,RedirectAttributes redirectAttributes) {
		HashMap<String,String> param = getParameter(request);
		String baseinfoId = param.get("ajzBaseinfoId");
		if(StringUtils.isNotBlank(baseinfoId)){
			AjzBaseinfo ajzBaseinfoByid = ajzBaseinfoService.get(baseinfoId);
			if(StringUtils.isBlank(ajzBaseinfoByid.getEnterpriseName())){
				addMessage(redirectAttributes, "请选择门店");
				return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/spNone";
			}
		}else if(StringUtils.isBlank(param.get("recordId"))){
			addMessage(redirectAttributes, "请选择门店");
			return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/spNone";
		}
		if(StringUtils.isNotBlank(param.get("recordId"))){
			ajzRecord = ajzRecordService.get(param.get("recordId"));
			baseinfoId = ajzRecord.getAjzBaseinfoId();
		}
		AjzBaseinfo ajzBaseinfo = ajzBaseinfoService.get(baseinfoId);
		model.addAttribute("ajzBaseinfo", ajzBaseinfo);
		model.addAttribute("ajzRecord", ajzRecord);
		return "modules/ajz/ajzSpRecordForm";
	}
	
	/*
	 * 删除食品隐患点
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:edit")
	@RequestMapping(value = "deleteSp")
	public String deleteSp(Model model,HttpServletRequest request,RedirectAttributes redirectAttributes){
		HashMap<String,String> param = getParameter(request);
		AjzRecord ajzRecord = ajzRecordService.get(param.get("recordId"));
		String ajzBaseinfoId = ajzRecord.getAjzBaseinfoId();
		ajzRecordService.delete(ajzRecord);
		return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/spNone?ajzBaseinfo.id="+ajzBaseinfoId+"";
	}
	
	/**
	 * 保存食品记录表
	 * @param ajzRecord
	 * @param model
	 * @param request
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "saveSpRecord")
	public String saveSpRecord(AjzRecord ajzRecord,Model model,HttpServletRequest request,RedirectAttributes redirectAttributes){
		if (!beanValidator(model, ajzRecord)){
			return spform(ajzRecord, model,request,redirectAttributes);
		}
		AjzBaseinfo ajzBaseinfo = ajzBaseinfoService.get(ajzRecord.getAjzBaseinfoId());
		ajzRecord.setBackup2(ajzBaseinfo.getParentId());
		ajzRecord.setType("ajz_sp");
		ajzRecordService.save(ajzRecord);
		addMessage(redirectAttributes, "保存食品表成功");
		return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/spNone?ajzBaseinfo.id="+ajzRecord.getAjzBaseinfoId()+"";
	}
	
	/*----------------------------------------------燃气管道--------------------------------------------------*/
	
	/*
	 * 燃气管道List
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "riGdNone")
	public String riGdNone(AjzRecord ajzRecord,HttpServletRequest request, HttpServletResponse response, Model model){
		HashMap<String,String> param = getParameter(request);
		String ajzBaseinfoId = param.get("ajzBaseinfo.id");
		if(StringUtils.isNotBlank(ajzBaseinfoId)){
			AjzBaseinfo ajzBaseinfoByid = ajzBaseinfoService.get(ajzBaseinfoId);
			if(StringUtils.isNotBlank(ajzBaseinfoByid.getEnterpriseName())){
				ajzRecord.setAjzBaseinfoId(ajzBaseinfoId);
			}else{
				ajzRecord.setBackup2(ajzBaseinfoByid.getId());
			}
		}
		User loginUser = UserUtils.getUser();
		if(!loginUser.isAdmin()){
			AjzBaseinfo ajzBaseinfo = ajzBaseinfoService.getAjzBaseinfoByOfficeId(loginUser.getOffice().getId());
			ajzRecord.setBackup2(ajzBaseinfo.getId());
		}
		ajzRecord.setType("ajz_ri_gd");
		Page<AjzRecord> page = ajzRecordService.findRealAjzRecordPageByBaseinfoId(new Page<AjzRecord>(request, response), ajzRecord); 
		model.addAttribute("page", page);
		model.addAttribute("ajzBaseinfoId",ajzBaseinfoId);
		return "modules/ajz/ajzRiGdRecordList";
	}
	
	//获取燃气管道的隐患内容
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "riGdform")
	public String riGdform(AjzRecord ajzRecord, Model model,HttpServletRequest request,RedirectAttributes redirectAttributes) {
		HashMap<String,String> param = getParameter(request);
		String baseinfoId = param.get("ajzBaseinfoId");
		if(StringUtils.isNotBlank(baseinfoId)){
			AjzBaseinfo ajzBaseinfoByid = ajzBaseinfoService.get(baseinfoId);
			if(StringUtils.isBlank(ajzBaseinfoByid.getEnterpriseName())){
				addMessage(redirectAttributes, "请选择门店");
				return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/riGdNone";
			}
		}else if(StringUtils.isBlank(param.get("recordId"))){
			addMessage(redirectAttributes, "请选择门店");
			return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/riGdNone";
		}
		if(StringUtils.isNotBlank(param.get("recordId"))){
			ajzRecord = ajzRecordService.get(param.get("recordId"));
			baseinfoId = ajzRecord.getAjzBaseinfoId();
		}
		AjzBaseinfo ajzBaseinfo = ajzBaseinfoService.get(baseinfoId);
		AjzRiGd ajzRiGd = ajzRiGdService.getRealajzRiGdByBaseinfo(baseinfoId);
		List<Dict> gasPropertyList = ajzBaseinfoService.findSelectList("gas_property");
		model.addAttribute("gasPropertyList", gasPropertyList);
		model.addAttribute("ajzRiGd", ajzRiGd);
		model.addAttribute("ajzBaseinfo", ajzBaseinfo);
		model.addAttribute("ajzRecord", ajzRecord);
		return "modules/ajz/ajzriGdRecordForm";
	}
	
	/*
	 * 删除燃气管道隐患点
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:edit")
	@RequestMapping(value = "deleteRiGd")
	public String deleteRiGd(Model model,HttpServletRequest request,RedirectAttributes redirectAttributes){
		HashMap<String,String> param = getParameter(request);
		AjzRecord ajzRecord = ajzRecordService.get(param.get("recordId"));
		String ajzBaseinfoId = ajzRecord.getAjzBaseinfoId();
		ajzRecordService.delete(ajzRecord);
		return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/riGdNone?ajzBaseinfo.id="+ajzBaseinfoId+"";
	}
	
	/**
	 * 保存燃气管道记录表
	 * @param ajzRecord
	 * @param model
	 * @param request
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "saveRiGdRecord")
	public String saveRiGdRecord(AjzRecord ajzRecord,Model model,HttpServletRequest request,RedirectAttributes redirectAttributes){
		if (!beanValidator(model, ajzRecord)){
			return riGdform(ajzRecord, model,request,redirectAttributes);
		}
		AjzBaseinfo ajzBaseinfo = ajzBaseinfoService.get(ajzRecord.getAjzBaseinfoId());
		ajzRecord.setBackup2(ajzBaseinfo.getParentId());
		ajzRecord.setType("ajz_ri_gd");
		ajzRecordService.save(ajzRecord);
		addMessage(redirectAttributes, "保存燃气管道表成功");
		return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/riGdNone?ajzBaseinfo.id="+ajzRecord.getAjzBaseinfoId()+"";
	}
	
	/*--------------------------------------------液化石油-------------------------------------------*/
	
	/*
	 * 燃气液化石油List
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "riGhNone")
	public String riGhNone(AjzRecord ajzRecord,HttpServletRequest request, HttpServletResponse response, Model model){
		HashMap<String,String> param = getParameter(request);
		String ajzBaseinfoId = param.get("ajzBaseinfo.id");
		if(StringUtils.isNotBlank(ajzBaseinfoId)){
			AjzBaseinfo ajzBaseinfoByid = ajzBaseinfoService.get(ajzBaseinfoId);
			if(StringUtils.isNotBlank(ajzBaseinfoByid.getEnterpriseName())){
				ajzRecord.setAjzBaseinfoId(ajzBaseinfoId);
			}else{
				ajzRecord.setBackup2(ajzBaseinfoByid.getId());
			}
		}
		User loginUser = UserUtils.getUser();
		if(!loginUser.isAdmin()){
			AjzBaseinfo ajzBaseinfo = ajzBaseinfoService.getAjzBaseinfoByOfficeId(loginUser.getOffice().getId());
			ajzRecord.setBackup2(ajzBaseinfo.getId());
		}
		ajzRecord.setType("ajz_ri_gh");
		Page<AjzRecord> page = ajzRecordService.findRealAjzRecordPageByBaseinfoId(new Page<AjzRecord>(request, response), ajzRecord); 
		model.addAttribute("page", page);
		model.addAttribute("ajzBaseinfoId",ajzBaseinfoId);
		return "modules/ajz/ajzRiGhRecordList";
	}
	
	//获取燃气液化石油的隐患内容
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "riGhform")
	public String riGhform(AjzRecord ajzRecord, Model model,HttpServletRequest request,RedirectAttributes redirectAttributes) {
		HashMap<String,String> param = getParameter(request);
		String baseinfoId = param.get("ajzBaseinfoId");
		if(StringUtils.isNotBlank(baseinfoId)){
			AjzBaseinfo ajzBaseinfoByid = ajzBaseinfoService.get(baseinfoId);
			if(StringUtils.isBlank(ajzBaseinfoByid.getEnterpriseName())){
				addMessage(redirectAttributes, "请选择门店");
				return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/riGhNone";
			}
		}else if(StringUtils.isBlank(param.get("recordId"))){
			addMessage(redirectAttributes, "请选择门店");
			return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/riGhNone";
		}
		if(StringUtils.isNotBlank(param.get("recordId"))){
			ajzRecord = ajzRecordService.get(param.get("recordId"));
			baseinfoId = ajzRecord.getAjzBaseinfoId();
		}
		AjzBaseinfo ajzBaseinfo = ajzBaseinfoService.get(baseinfoId);
		AjzRiGh ajzRiGh = ajzRiGhService.getRealAjzRiGhByBaseinfoId(baseinfoId);
		List<Dict> gasCompanyList = ajzBaseinfoService.findSelectList("gas_company");
		List<Dict> gasPropertyList = ajzBaseinfoService.findSelectList("gas_property");
		List<Dict> gasTypeList = ajzBaseinfoService.findSelectList("gas_type");
		List<Dict> purchaseVoucherList = ajzBaseinfoService.findSelectList("purchase_voucher");
		model.addAttribute("gasCompanyList", gasCompanyList);
		model.addAttribute("gasPropertyList", gasPropertyList);
		model.addAttribute("gasTypeList", gasTypeList);
		model.addAttribute("purchaseVoucherList", purchaseVoucherList);
		model.addAttribute("ajzRiGh", ajzRiGh);
		model.addAttribute("ajzBaseinfo", ajzBaseinfo);
		model.addAttribute("ajzRecord", ajzRecord);
		return "modules/ajz/ajzRiGhRecordForm";
	}
	
	/*
	 * 删除燃气液化石油隐患点
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:edit")
	@RequestMapping(value = "deleteRiGh")
	public String deleteRiGh(Model model,HttpServletRequest request,RedirectAttributes redirectAttributes){
		HashMap<String,String> param = getParameter(request);
		AjzRecord ajzRecord = ajzRecordService.get(param.get("recordId"));
		String ajzBaseinfoId = ajzRecord.getAjzBaseinfoId();
		ajzRecordService.delete(ajzRecord);
		return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/riGhNone?ajzBaseinfo.id="+ajzBaseinfoId+"";
	}
	
	/**
	 * 保存燃气液化石油表
	 * @param ajzRecord
	 * @param model
	 * @param request
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "saveRiGhRecord")
	public String saveRiGhRecord(AjzRecord ajzRecord,Model model,HttpServletRequest request,RedirectAttributes redirectAttributes){
		if (!beanValidator(model, ajzRecord)){
			return riGhform(ajzRecord, model,request,redirectAttributes);
		}
		AjzBaseinfo ajzBaseinfo = ajzBaseinfoService.get(ajzRecord.getAjzBaseinfoId());
		ajzRecord.setBackup2(ajzBaseinfo.getParentId());
		ajzRecord.setType("ajz_ri_gh");
		ajzRecordService.save(ajzRecord);
		addMessage(redirectAttributes, "保存燃气液化石油表成功");
		return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/riGhNone?ajzBaseinfo.id="+ajzRecord.getAjzBaseinfoId()+"";
	}
	
	/*---------------------------------出租屋----------------------------------------------*/
	
	/*
	 * 出租屋List
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "xfCzwNone")
	public String xfCzwNone(AjzRecord ajzRecord,HttpServletRequest request, HttpServletResponse response, Model model){
		HashMap<String,String> param = getParameter(request);
		String ajzBaseinfoId = param.get("ajzBaseinfo.id");
		if(StringUtils.isNotBlank(ajzBaseinfoId)){
			AjzBaseinfo ajzBaseinfoByid = ajzBaseinfoService.get(ajzBaseinfoId);
			if(StringUtils.isNotBlank(ajzBaseinfoByid.getEnterpriseName())){
				ajzRecord.setAjzBaseinfoId(ajzBaseinfoId);
			}else{
				ajzRecord.setBackup2(ajzBaseinfoByid.getId());
			}
		}
		User loginUser = UserUtils.getUser();
		if(!loginUser.isAdmin()){
			AjzBaseinfo ajzBaseinfo = ajzBaseinfoService.getAjzBaseinfoByOfficeId(loginUser.getOffice().getId());
			ajzRecord.setBackup2(ajzBaseinfo.getId());
		}
		ajzRecord.setType("ajz_xf_czw");
		Page<AjzRecord> page = ajzRecordService.findRealAjzRecordPageByBaseinfoId(new Page<AjzRecord>(request, response), ajzRecord); 
		model.addAttribute("page", page);
		model.addAttribute("ajzBaseinfoId",ajzBaseinfoId);
		return "modules/ajz/ajzXfCzwRecordList";
	}
	
	//获取出租屋的隐患内容
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "xfCzwform")
	public String xfCzwform(AjzRecord ajzRecord, Model model,HttpServletRequest request,RedirectAttributes redirectAttributes) {
		HashMap<String,String> param = getParameter(request);
		String baseinfoId = param.get("ajzBaseinfoId");
		if(StringUtils.isNotBlank(baseinfoId)){
			AjzBaseinfo ajzBaseinfoByid = ajzBaseinfoService.get(baseinfoId);
			if(StringUtils.isBlank(ajzBaseinfoByid.getEnterpriseName())){
				addMessage(redirectAttributes, "请选择门店");
				return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/xfCzwNone";
			}
		}else if(StringUtils.isBlank(param.get("recordId"))){
			addMessage(redirectAttributes, "请选择门店");
			return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/xfCzwNone";
		}
		if(StringUtils.isNotBlank(param.get("recordId"))){
			ajzRecord = ajzRecordService.get(param.get("recordId"));
			baseinfoId = ajzRecord.getAjzBaseinfoId();
		}
		AjzBaseinfo ajzBaseinfo = ajzBaseinfoService.get(baseinfoId);
		AjzXfCzw ajzXfCzw = ajzXfCzwService.getRealAjzXfCzwByBaseinfo(baseinfoId);
		model.addAttribute("ajzXfCzw", ajzXfCzw);
		model.addAttribute("ajzBaseinfo", ajzBaseinfo);
		model.addAttribute("ajzRecord", ajzRecord);
		return "modules/ajz/ajzXfCzwRecordForm";
	}
	
	/*
	 * 删除出租屋隐患点
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:edit")
	@RequestMapping(value = "deleteXfCzw")
	public String deleteXfCzw(Model model,HttpServletRequest request,RedirectAttributes redirectAttributes){
		HashMap<String,String> param = getParameter(request);
		AjzRecord ajzRecord = ajzRecordService.get(param.get("recordId"));
		String ajzBaseinfoId = ajzRecord.getAjzBaseinfoId();
		ajzRecordService.delete(ajzRecord);
		return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/xfCzwNone?ajzBaseinfo.id="+ajzBaseinfoId+"";
	}
	
	/**
	 * 保存消防出租屋记录表
	 * @param ajzRecord
	 * @param model
	 * @param request
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "saveXfCzwRecord")
	public String saveXfCzwRecord(AjzRecord ajzRecord,Model model,HttpServletRequest request,RedirectAttributes redirectAttributes){
		if (!beanValidator(model, ajzRecord)){
			return xfCzwform(ajzRecord, model,request,redirectAttributes);
		}
		AjzBaseinfo ajzBaseinfo = ajzBaseinfoService.get(ajzRecord.getAjzBaseinfoId());
		ajzRecord.setBackup2(ajzBaseinfo.getParentId());
		ajzRecord.setType("ajz_xf_czw");
		ajzRecordService.save(ajzRecord);
		addMessage(redirectAttributes, "保存出租屋消防表成功");
		return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/xfCzwNone?ajzBaseinfo.id="+ajzRecord.getAjzBaseinfoId()+"";
	}
	
	/*------------------------------店面--------------------------------------------*/
	
	/*
	 * 保存消防店面
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:edit")
	@RequestMapping(value = "saveXfDm")
	public String saveXfDm(AjzXfDm ajzXfDm, Model model, RedirectAttributes redirectAttributes) {
		if (!beanValidator(model, ajzXfDm)){
			return formXfDm(ajzXfDm, model);
		}
		ajzXfDmService.save(ajzXfDm);
		addMessage(redirectAttributes, "保存店面消防表成功");
		return "redirect:"+Global.getAdminPath()+"/ajz/ajzXfDm/?repage";
	}
	
	/*
	 *消防店面修改
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "formXfDm")
	public String formXfDm(AjzXfDm ajzXfDm, Model model) {
		model.addAttribute("ajzXfDm", ajzXfDm);
		return "modules/ajz/ajzXfDmForm";
	}
	
	/*
	 * 店面List
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "xfDmNone")
	public String xfDmNone(AjzRecord ajzRecord,HttpServletRequest request, HttpServletResponse response, Model model){
		HashMap<String,String> param = getParameter(request);
		String ajzBaseinfoId = param.get("ajzBaseinfo.id");
		if(StringUtils.isNotBlank(ajzBaseinfoId)){
			AjzBaseinfo ajzBaseinfoByid = ajzBaseinfoService.get(ajzBaseinfoId);
			if(StringUtils.isNotBlank(ajzBaseinfoByid.getEnterpriseName())){
				ajzRecord.setAjzBaseinfoId(ajzBaseinfoId);
			}else{
				ajzRecord.setBackup2(ajzBaseinfoByid.getId());
			}
		}
		User loginUser = UserUtils.getUser();
		if(!loginUser.isAdmin()){
			AjzBaseinfo ajzBaseinfo = ajzBaseinfoService.getAjzBaseinfoByOfficeId(loginUser.getOffice().getId());
			ajzRecord.setBackup2(ajzBaseinfo.getId());
		}
		ajzRecord.setType("ajz_xf_dm");
		Page<AjzRecord> page = ajzRecordService.findRealAjzRecordPageByBaseinfoId(new Page<AjzRecord>(request, response), ajzRecord); 
		model.addAttribute("page", page);
		model.addAttribute("ajzBaseinfoId",ajzBaseinfoId);
		return "modules/ajz/ajzRecordList";
	}
	
	//获取xfdm的隐患内容
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "xfDmform")
	public String xfDmform(AjzRecord ajzRecord, Model model,HttpServletRequest request,RedirectAttributes redirectAttributes) {
		HashMap<String,String> param = getParameter(request);
		String baseinfoId = param.get("ajzBaseinfoId");
		if(StringUtils.isNotBlank(baseinfoId)){
			AjzBaseinfo ajzBaseinfoByid = ajzBaseinfoService.get(baseinfoId);
			if(StringUtils.isBlank(ajzBaseinfoByid.getEnterpriseName())){
				addMessage(redirectAttributes, "请选择门店");
				return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/xfDmNone";
			}
		}else if(StringUtils.isBlank(param.get("recordId"))){
			addMessage(redirectAttributes, "请选择门店");
			return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/xfDmNone";
		}
		if(StringUtils.isNotBlank(param.get("recordId"))){
			ajzRecord = ajzRecordService.get(param.get("recordId"));
			baseinfoId = ajzRecord.getAjzBaseinfoId();
		}
		AjzBaseinfo ajzBaseinfo = ajzBaseinfoService.get(baseinfoId);
		AjzXfDm ajzXfDm = ajzXfDmService.getRealAjzXfDmByBaseinfoId(baseinfoId);
		List<Dict> placeCategoryList = ajzBaseinfoService.findSelectList("place_category");
		List<Dict> fireAuditList = ajzBaseinfoService.findSelectList("fire_audit");
		model.addAttribute("fireAuditList", fireAuditList);
		model.addAttribute("placeCategoryList", placeCategoryList);
		model.addAttribute("ajzXfDm", ajzXfDm);
		model.addAttribute("ajzBaseinfo", ajzBaseinfo);
		model.addAttribute("ajzRecord", ajzRecord);
		return "modules/ajz/ajzRecordForm";
	}
	
	/*
	 * 删除隐患点
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:edit")
	@RequestMapping(value = "deleteXfDm")
	public String deleteXfDm(Model model,HttpServletRequest request,RedirectAttributes redirectAttributes){
		HashMap<String,String> param = getParameter(request);
		AjzRecord ajzRecord = ajzRecordService.get(param.get("recordId"));
		String ajzBaseinfoId = ajzRecord.getAjzBaseinfoId();
		ajzRecordService.delete(ajzRecord);
		return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/xfDmNone?ajzBaseinfo.id="+ajzBaseinfoId+"";
	}
	
	/**
	 * 保存消防店面记录表
	 * @param ajzRecord
	 * @param model
	 * @param request
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "saveXfDmRecord")
	public String saveXfDmRecord(AjzRecord ajzRecord,Model model,HttpServletRequest request,RedirectAttributes redirectAttributes){
		if (!beanValidator(model, ajzRecord)){
			return xfDmform(ajzRecord, model,request,redirectAttributes);
		}
		AjzBaseinfo ajzBaseinfo = ajzBaseinfoService.get(ajzRecord.getAjzBaseinfoId());
		ajzRecord.setBackup2(ajzBaseinfo.getParentId());
		ajzRecord.setType("ajz_xf_dm");
		ajzRecordService.save(ajzRecord);
		addMessage(redirectAttributes, "保存店面消防表成功");
		return "redirect:"+Global.getAdminPath()+"/ajz/ajzBaseinfo/xfDmNone?ajzBaseinfo.id="+ajzRecord.getAjzBaseinfoId()+"";
	}
	
	/*
	 * 基础none
	 */
	@RequiresPermissions("ajz:ajzBaseinfo:view")
	@RequestMapping(value = "ajzNone")
	public String ajzNone(){
		return "modules/ajz/ajzNone";
	}

	@RequestMapping({"ajzType"})
	public String ajzType(AjzBaseinfo ajzBaseinfo, HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
		String userId = "29b66dbeaf244869a7a683747f79727a";
		User user = UserUtils.get(userId);
		System.out.println(userId);
		if(user == null) {
			user = new User();
		}

		Office office = user.getOffice();
		model.addAttribute("officeId", office.getId());
		return "modules/ajz/staff";
	}

	@RequestMapping({"ajzList"})
	public String ajzList(AjzBaseinfo ajzBaseinfo, HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
		String ajzType = request.getParameter("ajzType");
		String officeId = request.getParameter("officeId");
		System.out.println(ajzType + officeId);
		AjzBaseinfo currentAjzBaseinfo = this.ajzBaseinfoService.getAjzBaseinfoByOfficeId(officeId);
		if(null == currentAjzBaseinfo) {
			currentAjzBaseinfo = ajzBaseinfo;
		}

		List list = this.ajzBaseinfoService.findByTypeAndOffi(ajzType, currentAjzBaseinfo.getId());
		model.addAttribute("list", list);
		return "modules/ajz/e_query";
	}

	@RequestMapping({"recordList"})
	public String recordList(AjzBaseinfo ajzBaseinfo, HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
		String userId = "29b66dbeaf244869a7a683747f79727a";
		return "modules/ajz/staff2";
	}

	@RequestMapping({"myinfo"})
	public String myinfo(AjzBaseinfo ajzBaseinfo, HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
		String userId = "29b66dbeaf244869a7a683747f79727a";
		User user = UserUtils.get(userId);
		model.addAttribute("user", user);
		return "modules/ajz/staff3";
	}

	@RequestMapping({"qyinfo"})
	public String qyinfo(AjzBaseinfo ajzBaseinfo, HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
		String userId = "886d0bcd464e4c96bc7844974656302e";
		User user = UserUtils.get(userId);
		if(user == null) {
			user = new User();
		}

		AjzBaseinfo currentAjzBaseinfo = this.ajzBaseinfoService.get(user.getNo());
		model.addAttribute("info", currentAjzBaseinfo);
		return "modules/ajz/user";
	}

	@RequestMapping({"qyRecordList"})
	public String qyRecordList(AjzBaseinfo ajzBaseinfo, HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
		String userId = "886d0bcd464e4c96bc7844974656302e";
		return "modules/ajz/user2";
	}
}